﻿using AdventureWorks.DataAccess.repository;
using NUnit.Framework;
using AdventureWorks.DataAccess.SearchCriterias;
using AdventureWorks.Domain;
using NHibernate.Linq;
using System.Linq;
namespace AdventureWorks.DataAccess.Test.repository
{
    [TestFixture]
    public class ProductInventoryTest : RepositoryTestBase<ProductInventoryRepository>
    {
        [Test]
        public void When_search_on_product_should_return_correct_inventory()
        {
            var search = new ProductInventorySearchCriteria { ProductNumber = "AR-5381" };
            var products = repository.GetProductInventory(session, search).ToList<ProductInventory>();
            Assert.AreEqual(3, products.Count);
        }

        [Test]
        public void When_search_on_location_should_return_correct_inventory()
        {
            var search = new ProductInventorySearchCriteria { LocationName = "Tool Crib" };
            var products = repository.GetProductInventory(session, search).ToList<ProductInventory>();
            Assert.AreEqual(167, products.Count);
        }

        [Test]
        public void When_search_on_location_and_product_should_return_correct_inventory()
        {
            var search = new ProductInventorySearchCriteria { LocationName = "Tool Crib", ProductNumber = "AR-5381" };
            var products = repository.GetProductInventory(session, search).ToList<ProductInventory>();
            Assert.AreEqual(1, products.Count);
        }
    }

    
}
